fix: add missing option_home filter + flush rewrite rules on site duplication#770
Conversation
The register_filters() method filters option_siteurl but not option_home, causing get_permalink() to return the original subdomain URL instead of the mapped domain. This breaks CPT permalinks, Elementor preview, and admin AJAX on sites with domain mapping. Fixes Ultimate-Multisite#769
Cloned sites inherit the template's rewrite_rules option verbatim. If CPT permalink slugs were changed after the template was created, the cloned site returns 404 on those CPT URLs until the rules are regenerated. This adds a flush_rewrite_rules(true) call on the wu_duplicate_site hook. Fixes Ultimate-Multisite#769
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTwo related bug fixes address domain mapping and site duplication issues. The first adds a missing Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
superdav42
left a comment
There was a problem hiding this comment.
Auto-approved by pulse — collaborator PR (author: @kenedytorcatt). All pre-merge checks passed.
Summary
Fixes two bugs that cause 404 errors on custom post types and broken Elementor preview on subsites with domain mapping.
Discovered on a production multisite with 200+ subsites — affected 8 sites simultaneously.
Changes
1.
inc/class-domain-mapping.php— Add missingoption_homefilterregister_filters()addsoption_siteurlbut notoption_home. This causesget_permalink()to return the original subdomain URL instead of the mapped domain, breaking:Fix: Added
add_filter('option_home', [$this, 'mangle_url'], 20);to mirror the existingoption_siteurlfilter.2.
inc/compat/class-general-compat.php— Flush rewrite rules after site duplicationWhen UM duplicates a template site, the
rewrite_rulesoption is copied verbatim. If CPT permalink slugs were changed after the template was created, all cloned sites keep stale rules and return 404 on those CPT URLs.Fix: Added
flush_rewrite_rules_on_new_site()method hooked towu_duplicate_siteat priority 20.Related
Fixes #769
Testing
Summary by CodeRabbit